package com.blog.cmrpersonalblog.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 用户公告阅读记录实体类
 */
@Data
@TableName("user_announcement_read")
public class UserAnnouncementRead {

    /**
     * 记录ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 公告ID
     */
    @TableField("announcement_id")
    private Long announcementId;

    /**
     * 阅读状态 1-已读 2-忽略
     */
    @TableField("read_status")
    private Integer readStatus;

    /**
     * 阅读时间
     */
    @TableField(value = "read_time", fill = FieldFill.INSERT)
    private LocalDateTime readTime;

    /**
     * 判断是否已读
     */
    public boolean isRead() {
        return readStatus != null && readStatus == 1;
    }

    /**
     * 判断是否已忽略
     */
    public boolean isIgnored() {
        return readStatus != null && readStatus == 2;
    }
}
